var imageArrayRules = [];
var imageRules = {
    imgUrlRules:null
};
var image_list_length_rules = 1;
function rulesImageLoader() {
    var btnUpload = $('#upload_rules');
    var status = $('#status_rules');
    new AjaxUpload(btnUpload, {
        action:'/admin/add_image.html',
        name:'fileUpload',
        onSubmit:function (file, ext) {
            if (!(ext && /^(jpg|png|jpeg|gif)$/.test(ext))) {
                // extension is not allowed
                status.text('Only JPG, PNG or GIF files are allowed');
                return false;
            }
            status.text('Uploading...');
        },
        onComplete:function (file, response) {
            //On completion clear the status
            status.text('');
            //Add uploaded file to list
            var params = response.split(',');
            var name = params[1].split('/');
            var text;
            if (params[0] === "success") {
                $('<li></li>').appendTo('#files_rules').html('<img style="width: 200px; height: 200px" src=' + params[1] + ' alt="" /><br /><p>' + name[3] + '</p>').addClass('success');
                imageRules = {
                    imgUrlRules:params[1]
                }
                image_list_length_rules++;
                imageArrayRules.push(image);

            } else {
                $('<li></li>').appendTo('#files_rules').text(file).addClass('upload_error');
            }
        }
    });
}